﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ERPStore.Web.Extensions
{
	public static class WebApiExtensions
	{
		public static System.Net.Http.HttpContent ToContent(this ERPStore.Models.ValidationException vex)
		{
			var serializer = new System.Runtime.Serialization.DataContractSerializer(typeof(List<ERPStore.Models.BrokenRule>));
			string content = "Error";
			using (var ms = new System.IO.MemoryStream())
			{
				serializer.WriteObject(ms, vex.List);
				content = System.Text.Encoding.UTF8.GetString(ms.GetBuffer());
			}
			return new System.Net.Http.StringContent(content);
		}

	}
}
